-
Notifications
You must be signed in to change notification settings - Fork 122
Large code refactor to enable a bunch of additional ruff rulesets #1421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…xecutableness and shebang pressence
…inated else case when the if had a return
This reverts commit bf519a0.
…actorings" This reverts commit 374a885.
… list This rule forced every use of typing inside a cast to be quoted. In reality, it is only forward reference types which needed this.
…s like replace .format() with f-strings
…rings amd the like
…don't return anything
…ed until Python 3.11
Strategically disabled on various lines in cmd2 code where we are using subprocess.Popen() in a way it doesn't like as well as when we are using asserts intentionally like in transcript testing.
…e it clear they are intended for internal use only
I'm going to merge this in and start working on doing the merge to the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I enabled a bunch of additional
ruff
rulesets for our automated linting checks.In the process, I also ignored certain specific rules overall and other rules in certain files or directories.
The intent is to leave code a little bit cleaner and a little bit more modern and idiomatic as well as to make it easy for new contributors to comply with good best practices. The majority of the changes outside of
pyproject.toml
andMakefile
were automated refactoring done byruff.
Details
Ruff Rules are documented here.
Previously enabled and still enabled rulesets (untouched)
ASYNC
- flake8-aysncC90
- mccabeE
- pycodestyle errorsF
- pyflakesFA
- flake8-future-annotationsFLY
- flyntG
- flake8-logging-formatI
- isortICN
- flake8-import-conventionsINT
- flake8-gettextPLE
- Pylint ErrorRSE
- flake8-raiseT10
- flake8-debuggerTID
- flake8-tidy-importsW
- pycodestyle warningsEnabled ruff rulesets (compared to before this PR)
A
- flake8-builtinsBLE
- flake8-blind-exceptC4
- flake8-comprehensionsCOM
- flake8-commasDTZ
- flake8-datetimezERA
- eradicateEXE
- flake8-executableFIX
- flake8-fixmeFURB
- refurbINP
- flake8-no-pep420ISC
- flake8-implicit-str-concatLOG
- flake8-loggingN
- pep8-namingPERF
- PerflintPGH
- pygrep-hooksPIE
- flake8-piePLC
- Pylint ConventionPLW
- Pylint WarningPT
- flake8-pytest-stylePYI
- flake8-pyiQ
- flake8-quotesRET
- flake8-returnS
- flake8-banditSLOT
- flake8-slotsTC
- flake8-type-checkingTD
- flake8-todosUP
- pyupgradeYTT
- flake8-2020Disabled by this PR because they are for frameworks cmd2 doesn't use
AIR
- AirflowDJ
- DjangoFAST
- FastAPINPY
- NumPyPD
- PandasStill disabled ruff rulesets
Rules that would probably be good to eventually enable
ANN
- flake8-annotationsARG
- flake8-unused-argumentsD
- pydocstyle (very low priority)PTH
- flake8-use-pathlib (low priority)RUF
- Ruff-specific rulesSIM
- flake8-simplifySLF
- flake8-selfTRY
- tryceratops (low priority)Rules we might want to enable once they are out of preview
DOC
- pydoclint (ruff preview not fully released)Rules we probably never want to enable
B
- flake8-bugbear (too many false positives)CPY
- flake8-copyright (no need to force a copyright message at top of every file)EM
- flake8-errmsg (no need to force setting local variable before throwing exception)FBT
- flake8-boolean-trap (forces all boolean parameters to be passed by keyword and not position)PLR
- Pylint Refactor (too many false positives)T20
- flake8-print (cmd2 uses print directly under the hood)